|
|
|
|
|
|
|
Examples Filename: FileRead.frm |
|
|
|
|
|
|
|
|
In the form shown in Figure 20.4, youll select a file to read using the file controls. |
|
|
|
|
|
|
|
|
Figure 20.4
Reading information from a file. |
|
|
|
|
|
|
|
|
Once the file is highlighted in the Select File to Read list box, you click the Read command button. In the Click event of the Read button is where youll open the file and read in each line until you hit the end of the file: |
|
|
|
 |
|
|
|
|
Private Sub cmdRead_Click()
Dim oFile As TextStream
Dim strValue As String
Dim strFileName As String
Screen.MousePointer = vbHourglass
strFileName = GetFileName()
Set oFile = New TextStream
With oFile .FileName = strFileName ' Check For File Too Big - 32K limit on text boxes If .FileTooBig Then Beep
Screen.MousePointer = vbDefault
MsgBox "File Too Big To Read", , "File Open Error"
Else |
|
|
|
|
|